<?php

/**
 * Transaction form base class.
 *
 * @method Transaction getObject() Returns the current form's model object
 *
 * @package    Bojss
 * @subpackage form
 * @author     Atu
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseTransactionForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                    => new sfWidgetFormInputHidden(),
      'user_id'               => new sfWidgetFormInputText(),
      'store_id'              => new sfWidgetFormInputText(),
      'linked_trans_id'       => new sfWidgetFormInputText(),
      'linked_trans_user_id'  => new sfWidgetFormInputText(),
      'linked_trans_store_id' => new sfWidgetFormInputText(),
      'trans_date'            => new sfWidgetFormDate(),
      'is_income'             => new sfWidgetFormInputText(),
      'trans_type'            => new sfWidgetFormInputText(),
      'trans_entity_id'       => new sfWidgetFormInputText(),
      'total_price'           => new sfWidgetFormInputText(),
      'customer_name'         => new sfWidgetFormInputText(),
      'customer_phone'        => new sfWidgetFormInputText(),
      'is_active'             => new sfWidgetFormInputText(),
      'created_at'            => new sfWidgetFormDateTime(),
      'updated_at'            => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                    => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'user_id'               => new sfValidatorInteger(),
      'store_id'              => new sfValidatorInteger(),
      'linked_trans_id'       => new sfValidatorInteger(),
      'linked_trans_user_id'  => new sfValidatorInteger(),
      'linked_trans_store_id' => new sfValidatorInteger(),
      'trans_date'            => new sfValidatorDate(),
      'is_income'             => new sfValidatorInteger(array('required' => false)),
      'trans_type'            => new sfValidatorInteger(),
      'trans_entity_id'       => new sfValidatorInteger(),
      'total_price'           => new sfValidatorNumber(),
      'customer_name'         => new sfValidatorString(array('max_length' => 255)),
      'customer_phone'        => new sfValidatorString(array('max_length' => 8)),
      'is_active'             => new sfValidatorInteger(array('required' => false)),
      'created_at'            => new sfValidatorDateTime(),
      'updated_at'            => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('transaction[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Transaction';
  }

}
